package com.lkl.spring.controller;

import com.lkl.spring.annotation.LklAutowird;
import com.lkl.spring.annotation.LklController;
import com.lkl.spring.annotation.LklRequestMapping;
import com.lkl.spring.annotation.LklResponseBody;
import com.lkl.spring.service.UserService;

import java.util.HashMap;
import java.util.Map;

@LklController(value = "indexController")
@SuppressWarnings("all")
public class IndexController {

    @LklAutowird
    private UserService userService;

    /**
     * 启动首页
     * @return
     */
    @LklRequestMapping("/index")
    public String index() {
        System.out.println("this is indexController index excute");
        return "index";
    }

    /**
     * 跳转登录首页
     * @return
     */
    @LklRequestMapping("/login")
    public String login () {
        System.out.println("登录页面...");
        return "login";
    }

    /**
     * 返回添加用户的结果
     * @return
     */
    @LklResponseBody("/addUser")
    @LklRequestMapping("/addUser")
    public Map addUser () {
        userService.addUser();
        Map mapReturn = new HashMap<String, String>();
        mapReturn.put("status", 200);
        mapReturn.put("message", "处理完成");
        return mapReturn;
    }

}
